package com.ucode.model.cgms.enums;

import cn.hutool.core.util.ArrayUtil;
import com.ucode.tool.base.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 陪玩订单状态
 *
 * @author ll
 */
@AllArgsConstructor
@Getter
public enum CgmsCompanionOrderStatusEnum implements IntArrayValuable {

    // 核心流程状态
    PENDING_PAYMENT(1,"待支付（初始状态）"),
    DISPATCHING(2,"派单中（支付成功后触发）"),
    PENDING_CONFIRM(3,"待确认（陪玩接单确认）"),
    IN_SERVICE(4,"服务中（陪玩确认后）"),
    END_SERVICE(5,"服务结束（陪玩报备后）"),
    COMPLETED(6,"已完成（用户确认后）"),
    AFTER_SALE(8,"售后中（用户发起投诉/退款）"),
    AFTER_SALE_DONE(9,"已售后（全部售后）"),   // 售后完成
    CANCELLED(10,"已取消（用户主动取消或超时）")
    ;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CgmsCompanionOrderStatusEnum::getState).toArray();

    public static CgmsCompanionOrderStatusEnum get(Integer code) {
        return ArrayUtil.firstMatch(o -> o.getState().equals(code), values());
    }
    /**
     * 状态
     */
    private final Integer state;
    /**
     * 名称
     */
    public final String message;

    public Integer getCode() {
        return state;
    }


    public String getMessage() {
        return message;
    }


    @Override
    public int[] array() {
        return ARRAYS;
    }

}
